package program

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method 'GET'
        url value(consumer(regex('/api/v2/tags')),
                producer('/api/v2/tags'))
        headers {
            contentType(applicationJsonUtf8())
        }
    }
    response {
        status(200)
        headers {
            contentType(applicationJsonUtf8())
        }
        body("""
            [{
                "id": 2,
               "name":"second"
            }]
        """)
        bodyMatchers {
            jsonPath('$.[*]', byType())
            jsonPath('$.[*].id', byRegex(number()))
            jsonPath('$.[*].name', byRegex(nonBlank()))
        }
    }

}